﻿using INTEX.DataBase;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Globalization;
using System.IO;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using ReflectionStudio.Core.Events;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class TPRNDEF
    { 
        #region ==dwKDF===========
        public static readonly DependencyProperty dwKDFProperty = DependencyProperty.Register("dwKDF",
            typeof(DataRow), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwKDFChanged));
        public DataRow dwKDF
        {
            get
            {
                return (DataRow)GetValue(dwKDFProperty);
            }
            set
            {
                SetValue(dwKDFProperty, value);
            }
        }
        private static void OdwKDFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwKDF = row;
                src.Load(row);
            }
        }
        #endregion
        #region ==dwPCT===========
        public static readonly DependencyProperty dwPCTProperty = DependencyProperty.Register("dwPCT",
            typeof(DataRow), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwPCTChanged));
        public DataRow dwPCT
        {
            get
            {
                return (DataRow)GetValue(dwPCTProperty);
            }
            set
            {
                SetValue(dwPCTProperty, value);
            }
        }
        private static void OdwPCTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwPCT = row; 
                src.PCTCHG();
            }
        }
        #endregion
        #region ==dwTPCT===========
        public static readonly DependencyProperty dwTPCTProperty = DependencyProperty.Register("dwTPCT",
            typeof(DataRow), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwTPCTChanged));
        public DataRow dwTPCT
        {
            get
            {
                return (DataRow)GetValue(dwTPCTProperty);
            }
            set
            {
                SetValue(dwTPCTProperty, value);
            }
        }
        private static void OdwTPCTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwTPCT = row;
                src.TPCTCHG();
            }
        }
        #endregion
        #region ==dwPRN===========
        public static readonly DependencyProperty dwPRNProperty = DependencyProperty.Register("dwPRN",
            typeof(DataRow), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwPRNChanged));
        public DataRow dwPRN
        {
            get
            {
                return (DataRow)GetValue(dwPRNProperty);
            }
            set
            {
                SetValue(dwPRNProperty, value);
            }
        }
        private static void OdwPRNChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwPRN = row; 
            }
        }
        #endregion

        #region ==KDF===========
        public static readonly DependencyProperty KDFProperty = DependencyProperty.Register("KDF",
            typeof(string), typeof(TPRNDEF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKDFChanged));
        public string KDF
        {
            get
            {
                return (string)GetValue(KDFProperty);
            }
            set
            {
                SetValue(KDFProperty, value);
            }
        }
        private static void OnKDFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                src.KDF = (string)e.NewValue;
            }
        }
        #endregion
        #region ==LINE===========
        public static readonly DependencyProperty LINEProperty = DependencyProperty.Register("LINE",
            typeof(int), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLINEChanged));
        public int LINE
        {
            get
            {
                return (int)GetValue(LINEProperty);
            }
            set
            {
                SetValue(LINEProperty, value);
            }
        }
        private static void OnLINEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                src.LINE = (int)e.NewValue;
            }
        }
        #endregion
        #region ==LHEIGHT===========
        public static readonly DependencyProperty LHEIGHTProperty = DependencyProperty.Register("LHEIGHT",
            typeof(int), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLHEIGHTChanged));
        public int LHEIGHT
        {
            get
            {
                return (int)GetValue(LHEIGHTProperty);
            }
            set
            {
                SetValue(LHEIGHTProperty, value);
            }
        }
        private static void OnLHEIGHTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                src.LHEIGHT = (int)e.NewValue;
            }
        }
        #endregion
        #region ==TOPY===========
        public static readonly DependencyProperty TOPYProperty = DependencyProperty.Register("TOPY",
            typeof(int), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTOPYChanged));
        public int TOPY
        {
            get
            {
                return (int)GetValue(TOPYProperty);
            }
            set
            {
                SetValue(TOPYProperty, value);
            }
        }
        private static void OnTOPYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                src.TOPY = (int)e.NewValue;
            }
        }
        #endregion

        #region ==LSX===========
        public static readonly DependencyProperty LSXProperty = DependencyProperty.Register("LSX",
            typeof(int), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLSXChanged));
        public int LSX
        {
            get
            {
                return (int)GetValue(LSXProperty);
            }
            set
            {
                SetValue(LSXProperty, value);
            }
        }
        private static void OnLSXChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                src.LSX = (int)e.NewValue;
            }
        }
        #endregion
        #region ==LMX===========
        public static readonly DependencyProperty LMXProperty = DependencyProperty.Register("LMX",
            typeof(int), typeof(TPRNDEF),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLMXChanged));
        public int LMX
        {
            get
            {
                return (int)GetValue(LMXProperty);
            }
            set
            {
                SetValue(LMXProperty, value);
            }
        }
        private static void OnLMXChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TPRNDEF;
            if (src != null)
            {
                src.LMX = (int)e.NewValue;
            }
        }
        #endregion
       public TPRNDEF()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_PRNDEF();
            TOPY = 50;
            LHEIGHT = 50;
            LSX = 50;
            LMX = 270;
            IsMasterFromMV = true;
            TBMain = MV.SetProd.Tables[TB]; 
            InitializeComponent(); 
        }
       
        /// <summary>
        /// SetProd 当前订单
        /// SetData保存所有订单，但是用于展示今日订单
        /// SetEnv保存所有订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
       public override void Window_Loaded(object sender, RoutedEventArgs e)
       {
           if (DesignerProperties.GetIsInDesignMode(this))
               return;
           base.Window_Loaded(sender, e);
       }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwPRN = dwMaster;
        }
        public void Load(DataRow _dwKDF)
        {
            if (_dwKDF == null)
                return;

            DataRow dwData = TBMain.NewRow();
            dwData["MANDANT"] = _dwKDF["KDFMANDANT"];
            dwData["KUNDNR"] = _dwKDF["KDFKUNDNR"];
            dwData["PRNAME"] = Helper.Left(_dwKDF["KDFFORMULAR1"].ToString().PadRight(20), 20);
            DataSet SResult = ((VICC_PRNDEF)MV).QueryICC_PRNDEF(dwData, 2);
            MergeData(SResult, true,true);
        }
        public void CHGKDF(DataRow _dwKDF)
        {
            foreach (DataRow row in TBMain.Rows)
            {
                row["KUNDNR"] = _dwKDF["KDFKUNDNR"];
                row["PRNAME"] = Helper.Left(_dwKDF["KDFFORMULAR1"].ToString().PadRight(20), 20);
                Update(row);
            }
        }
        public void Update(DataRow _dwPRN)
        {
            ((VICC_PRNDEF)MV).UpdateICC_PRNDEF(_dwPRN, 0);
        }
        public override void New()
        {
            
            try
            {
                DataRow dwData = TBMain.NewRow();
                ((VICC_PRNDEF)MV).SetUpNewRow(ref dwData);
                if (dwPRN != null)
                {
                    dwData.ItemArray = dwPRN.ItemArray;
                }
                else
                {
                    dwData["KUNDNR"] = dwKDF["KDFKUNDNR"];
                }
                dwData["PRNAME"] = dwKDF["KDFFORMULAR1"];
                dwData["ROWNID"] = INTEXDBC.GetSeq();
                dwData["PRVER"] = "0";
                dwData["PRCOND"] = LINE;
                dwData["PRCONTENT"] = " ";
                dwData["PRCONTDES"] = "  ";
                Insert(dwData); 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }  
        }
        public void Insert(DataRow _dwPRN)
        {
            TBMain.Rows.InsertAt(_dwPRN, 0);
            vwMaster.View.MoveCurrentToFirst();
            ((VICC_PRNDEF)MV).InsertICC_PRNDEF(_dwPRN, app.company);
        }
        public override void Delete()
        {
            base.Delete();
            if (dwMaster == null)
                return;
            ((VICC_PRNDEF)MV).DeleteICC_PRNDEF(dwMaster, 1);
            string ROWNID = dwMaster["ROWNID"].ToString();
            string filter = "ROWNID='" + ROWNID + "'";
            vwMaster.View.MoveCurrentTo(-1);
            DataRow[] rows = TBMain.Select(filter);
            foreach (DataRow row in rows)
            {
                row.Delete();
            }
            TBMain.AcceptChanges(); 
        }
        public override void Save()
        {
            if (dwMaster == null)
                return;
            ((VICC_PRNDEF)MV).UpdateICC_PRNDEF(dwMaster, 0);
        }
        public  void Copy(DataRow _dwKDF)
        {
            if (dwKDF == null)
            {
                MessageBox.Show("请从左边选择一个格式");
                return;
            }
            Load(_dwKDF);
            CHGKDF(dwKDF);
        }
        ITXPRNReport m_rpt;
        private void cmdPRNConvert_Click(object sender, RoutedEventArgs e)
        {
            DataSet setResult = null;
            try
            {
                DataSet setRpt = new DataSet();

                m_rpt = new ITXPRNReport();
                m_rpt.dsSource = new DataSet();
                m_rpt.dsSource.Merge(TBMain);
                m_rpt.WriteExcelReport("OpenExcel");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        } 
        
        public override void NewCommand(object sender, RoutedEventArgs e)
        {
            New();
            base.NewCommand(sender, e);
        }
        public override void SaveCommand(object sender, RoutedEventArgs e)
        {
            Save();
            base.SaveCommand(sender, e); 
        }

        public override void DeleteCommand(object sender, RoutedEventArgs e)
        {
            Delete();
            base.DeleteCommand(sender, e);
        }
        public override void CopyCommand(object sender, RoutedEventArgs e)
        {
            Copy(cSKD09.dwKDF);
            base.CopyCommand(sender, e);
        }
        public ExcelX.ExcelLib.ExcelAgent exAgent;
        public void Convert2PRNDEF(DataSet DB)
        {
            if (dwMaster!=null)
            { 
                ((VICC_PRNDEF)MV).DeleteICC_PRNDEF(dwMaster,3);
            }
            TBMain.Clear(); 
            string lineid = "";
            string value = "";
            string cname = "";
            DataRow dwPrn;
            int x = 0;
            int y = 0;
            foreach (DataRow RX in DB.Tables[0].Rows)
            {
                x++;
                lineid = RX["C1"].ToString();
                if (lineid == "") continue;
                LINE = Convert.ToInt16(lineid);
                y = 0;
                foreach (DataColumn cm in DB.Tables[0].Columns)
                {
                    y++;
                    cname = cm.ColumnName;
                    if (cname == "C1")
                    {
                        continue;
                    }
                    value = RX[cname].ToString();
                    if (value.Trim() == "")
                        continue;
                    //value = value.Replace("##", "#");
                    value = value.Replace("0034", "_TN3");
                    value = value.Replace("#coilno#", "_T04");
                    value = value.Replace("#designno#", "_T06");
                    value = value.Replace("#lengthyds#", "_TCI");
                    value = value.Replace("123456789012", "_T01");
                    dwPrn = TBMain.Rows.Add();
                    ((VICC_PRNDEF)MV).SetUpNewRow(ref dwPrn);
                    dwPrn["ROWNID"] = INTEXDBC.GetSeq();
                    dwPrn["PRVER"] = "0";
                    LineSet(dwPrn);
                    if (y <=2)
                    {
                        dwPrn["PRLX"] = LSX;
                    }
                    else
                    {
                        dwPrn["PRLX"] = LMX;
                    }
                    dwPrn["PRCONTENT"] = value;
                    if (value.Contains("_T01"))
                    {
                        dwPrn["PRCTYPE"] = "B";
                        dwPrn["PRCONTDES"] = Helper.ConvertGB2312To8859P1("卷号条码");
                    }  
                    dwPrn["KUNDNR"] = dwKDF["KDFKUNDNR"];
                    dwPrn["PRNAME"] = Helper.Left(dwKDF["KDFFORMULAR1"].ToString().PadRight(20), 20);
                    ((VICC_PRNDEF)MV).InsertICC_PRNDEF(dwPrn, app.company);
                } 
            }
        }
        private void cmdPRNExcel_Click(object sender, RoutedEventArgs e)
        {
            if (dwKDF == null)
            {
                MessageBox.Show("请先选择一个客户的格式");
                return;
            }
            exAgent = new ExcelX.ExcelLib.ExcelAgent();
            DataSet SResult = null; 
            string fileroot = @"C:\IntexReport\Data\JLTBQ\EXCEL";
            string[] files = System.IO.Directory.GetFiles(fileroot);
            string filtername = "";
            foreach (string file in files)
            {
                filtername = file;
                string ShortName = file.Substring(file.LastIndexOf("\\") + 1);
                if (!ShortName.StartsWith("BQ"))
                    continue;
                EventDispatcher.Instance.RaiseStatus("装载:" + ShortName + "开始", StatusEventType.StopProgress);
                if (exAgent == null)
                {
                    exAgent = new ExcelX.ExcelLib.ExcelAgent(file);
                }
                if (System.IO.File.Exists(file))
                {
                    SResult = exAgent.LoadExcel(file, "BQ", 50, 50);
                }
                break;
            }
            exAgent.Close();
            System.IO.File.Move(filtername, filtername.Replace("EXCEL", "01Temp"));
            if (SResult.Tables.Count == 0)
                return;
            if (SResult.Tables[0].Rows.Count == 0)
                return;
            Convert2PRNDEF(SResult);
        }
        public  override void PrintCommand(object sender, RoutedEventArgs e)
        {
            // Base Image
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(Helpers.Helper.ApplicationPath + "\\WBD10IT.jpg", UriKind.Absolute);
            bi.DecodePixelWidth = 200;
            bi.EndInit();

            FormattedText str = null;
            DrawingVisual drawingVisual = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();
            drawingContext.DrawImage(bi, new Rect(0, 0, 1180, 500));
            var query = from DataRow row in TBMain.AsEnumerable()
                        orderby Convert.ToDecimal(row.Field<string>("PRLY")),
                       Convert.ToDecimal(row.Field<string>("PRLX"))
                        select row;
            foreach (DataRow row in query)
            {
                //PRLX	PRLY	PRRX	PRRY	PRLTHICK	PRCTYPE	 	PRFONT	PRFONTSIZE	PRCONTENT
                string PRDES = row["PRDES"].ToString().Trim();
                if (PRDES == "N")
                    continue;
                string text = "";
                string PRLX = row["PRLX"].ToString().Trim();
                string PRLY = row["PRLY"].ToString().Trim();
                string PRRX = row["PRRX"].ToString().Trim();
                string PRRY = row["PRRY"].ToString().Trim();
                string PRLTHICK = row["PRLTHICK"].ToString().Trim();
                string PRCTYPE = row["PRCTYPE"].ToString().Trim();
                string PRFONT = Helpers.Helper.GetGB2312Value(row["PRFONT"].ToString().Trim());
                string PRFONTSIZE = row["PRFONTSIZE"].ToString().Trim();
                string PRCONTENT = Helpers.Helper.GetGB2312Value(row["PRCONTENT"].ToString().Trim());
                string PRCONTDES = Helpers.Helper.GetGB2312Value(row["PRCONTDES"].ToString().Trim());

                switch (PRCTYPE)
                {
                    case "X":
                        //X,40,40,4,1180,560
                        //PRLX	PRLY	PRRX	PRRY	PRLTHICK
                        text = "X," + PRLX + "," + PRLY + "," + PRLTHICK + "," + PRRX + "," + PRRY;
                        break;
                    case "G":
                        //X,40,40,4,1180,560
                        //PRLX	PRLY	PRRX	PRRY	PRLTHICK
                        text = "G," + PRLX + "," + PRLY + "," + txtFileRoot.Text + "\\" + PRCONTENT;
                        break;
                    case "H":
                        //H,40,152,1140,2
                        text = "H," + PRLX + "," + PRLY + "," + PRRX + "," + PRLTHICK;
                        break;
                    case "A":
                        //A,微软雅黑,50,50,320,0,4,1,2,N,客户品种Yours:\N4
                        text = "A," + PRFONT + "," + PRFONTSIZE + "," + PRLX + "," + PRLY + ",0,4,1,2,N," + PRCONTENT.Replace("_T", "\\");
                        str = new FormattedText(PRCONTENT.Replace("_T", "\\"),
                            new CultureInfo("en-us"),
                            FlowDirection.LeftToRight,
                            new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.Normal, new FontStretch()),
                            10 + Convert.ToDouble(PRFONTSIZE) / 10,
                            Brushes.Black);
                        drawingContext.DrawText(str, new Point(Convert.ToDouble(PRLX) / 2, Convert.ToDouble(PRLY) / 2));
                        break;
                    case "B":
                        //B,50,390,0,3,4,8,100,N,\48
                        text = "B," + PRLX + "," + PRLY + ",0,3,4,8," + PRRY + ",N," + PRCONTENT.Replace("_T", "\\");
                        break;
                    case "b":
                        //b30,200,Q,m1,s3,eM,iA,"0053 33 -59"
                        text = "b," + PRLX + "," + PRLY + ",Q,m1,s3,eM,iA," + PRCONTENT.Replace("_T", "\\");
                        break;
                }
            }

            // Text to render on the image.
            // The Visual to use as the source of the RenderTargetBitmap. 
            drawingContext.Close();
            // The BitmapSource that is rendered with a Visual.
            RenderTargetBitmap rtb = new RenderTargetBitmap(400, 300, 96, 96, PixelFormats.Pbgra32);
            rtb.Render(drawingVisual);
            // Encoding the RenderBitmapTarget as a PNG file.
            PngBitmapEncoder png = new PngBitmapEncoder();
            png.Frames.Add(BitmapFrame.Create(rtb));
            if (!System.IO.Directory.Exists("C:\\IntexReport\\Temp"))
            {
                System.IO.Directory.CreateDirectory("C:\\IntexReport\\Temp");
            }
            string file = "C:\\IntexReport\\Temp\\PWB" + Guid.NewGuid().ToString() + ".png";
            using (Stream stm = File.Create(file))
            {
                png.Save(stm);
            }
            RefreshImage(file);
        }
        private void RefreshImage(string file)
        {
            // Create source
            BitmapImage bmp = new BitmapImage();

            // BitmapImage.UriSource must be in a BeginInit/EndInit block
            bmp.BeginInit();
            bmp.CacheOption = BitmapCacheOption.OnLoad;

            bmp.UriSource = new Uri(file);

            // To save significant application memory, set the DecodePixelWidth or   
            // DecodePixelHeight of the BitmapImage value of the image source to the desired  
            // height or width of the rendered image. If you don't do this, the application will  
            // cache the image as though it were rendered as its normal size rather then just  
            // the size that is displayed. 
            // Note: In order to preserve aspect ratio, set DecodePixelWidth 
            // or DecodePixelHeight but not both.
            bmp.DecodePixelWidth = 200;
            bmp.EndInit();
            //set image source
            this.imgpriew.Source = bmp;

        }
        private void btnLSX_Click(object sender, RoutedEventArgs e)
        {
            dwKDF["PRLX"] = LSX;
        }
        private void btnLMX_Click(object sender, RoutedEventArgs e)
        {
            dwKDF["PRLX"] =LMX;
        }
        public void LineSet(DataRow _dwKDF)
        {
            _dwKDF["PRCOND"] = Helper.Right("000" + LINE.ToString(), 4);
            _dwKDF["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
        }
        private void btnLINESet_Click(object sender, RoutedEventArgs e)
        {
            LineSet(dwKDF);
        }
      
        private void btnLINE_Click(object sender, RoutedEventArgs e)
        {
            LINE = LINE + 1;
        }
        public void PCTCHG()
        {
            if (dwPCT == null)
                return;
            if (dwPRN == null)
                return;
            dwPRN["PRCTYPE"] = dwPCT["PCTYPE"];
            dwPRN["PRCTYPDES"] = dwPCT["PCDES"].ToString();
            switch (dwPCT["PCTYPE"].ToString().Trim())
            {
                case "X":
                    dwPRN["PRLX"] = LSX;
                    dwPRN["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
                    dwPRN["PRRX"] = 1180;
                    dwPRN["PRRY"] = 560;
                    dwPRN["PRLTHICK"] = 4;
                    dwPRN["PRCONTENT"] = " ";
                    dwPRN["PRCONTDES"] = "  ";
                    break;
                case "H":
                    dwPRN["PRLX"] =LSX;
                    dwPRN["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
                    dwPRN["PRRX"] = 1140;
                    dwPRN["PRLTHICK"] = 2;
                    dwPRN["PRCONTENT"] = " ";
                    dwPRN["PRCONTDES"] = "  ";
                    break;
                case "G":
                    dwPRN["PRLX"] = LSX;
                    dwPRN["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
                    dwPRN["PRCONTENT"] = " ";
                    dwPRN["PRCONTDES"] = txtFileRoot.Text;
                    break;
                case "B":
                    dwPRN["PRLX"] = LSX;
                    dwPRN["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
                    dwPRN["PRRX"] = 0;
                    dwPRN["PRRY"] = 100;
                    dwPRN["PRLTHICK"] = 4;
                    dwPRN["PRCONTENT"] = "_T48";
                    dwPRN["PRCONTDES"] = Helper.ConvertGB2312To8859P1("卷号条码");
                    break;
                case "b":
                    dwPRN["PRLX"] = LSX;
                    dwPRN["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
                    dwPRN["PRRX"] = 1140;
                    dwPRN["PRLTHICK"] = 2;
                    dwPRN["PRCONTENT"] = "_T48";
                    dwPRN["PRCONTDES"] = Helper.ConvertGB2312To8859P1("卷号条码");
                    break;
                case "A":
                    dwPRN["PRLX"] = LSX;
                    dwPRN["PRLY"] = (LINE - 1) * LHEIGHT + TOPY;
                    dwPRN["PRFONT"] = Helper.ConvertGB2312To8859P1("微软雅黑");
                    dwPRN["PRFONTSIZE"] = 40;
                    dwPRN["PRRX"] = 0;
                    dwPRN["PRRY"] = 0;
                    dwPRN["PRCONTENT"] = Helper.ConvertGB2312To8859P1("请输入:");
                    break;
            }
        }
        public void TPCTCHG()
        {
            if (dwTPCT == null)
                return;
            if (dwPRN == null)
                return;
           string content=dwTPCT["PCTYPE"].ToString().Trim();
            
            string ctype = dwPRN["PRCONTENT"].ToString().Trim();
            string cdes = dwPRN["PRCONTDES"].ToString().Trim();
            if (ctype.Contains(content))
                return;
            dwPRN["PRCONTENT"] = ctype + content;
            dwPRN["PRCONTDES"] = dwTPCT["PCDES"].ToString();
            dwPRN["PRCTYPE"] = "A    ";
            dwPRN["PRCTYPDES"] = Helper.ConvertGB2312To8859P1("文字");
            dwPRN["PRFONT"] = Helper.ConvertGB2312To8859P1("微软雅黑");
            dwPRN["PRFONTSIZE"] = 40;
            dwPRN["PRRX"] = 0;
            dwPRN["PRRY"] = 0;
        } 
    }
}
